#ifndef _NAVMESH_GEN_H_
#define _NAVMESH_GEN_H_

#include "vec2.h"

typedef struct {
	vec2 v[2];
} navGenEdge;

typedef struct navmeshTri {
	vec2 v[3]; // The three points that construct this triangle. v1 always has the highest x value, and the vectors are in counter-clockwise order.
	struct navmeshTri *t[3]; // The tri's attached to the faces of this triangle. t1 is attached v1,v2, t2 is attached to v2,v3, and t3 is attached to v3,v1.
	int ts[3]; // What kind of connection there is between tri's. (0 = passable, 1 = unpassable)
	int path; // Used for pathfinding.
} navGenTri;

// Init
void navGenInit(void);

// Resets the contents of navgen.
void navGenReset();

// Passes a heap of edges to navgen for usage.
void navGenSetEdges(navGenEdge* e, unsigned int len);
// Runs navgen.
void navGenRun(void);

// Gets the amount of navgen Triangles that were generated.
unsigned int navGenGetTriCount(void);
// Fetches a navgen triangle. The id must be smaller than navGenGetTriCount();
navGenTri* navGenGetTri(unsigned int id);
// Fetches the navgen triangle in which the position can be found, and writes it to the given pointer. Returns 0 on success and 1 on failure.
int navGenGetTriPos(vec2 pos, navGenTri* t);

#endif

